#! /bin/sh /usr/share/dpatch/dpatch-run
## 07_gdb.a.dpatch by  <Torsten Werner <twerner@debian.org>>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Merge some stuff from trunk to gdbint.pp to support gdb version
## DP: 6.7.x.

@DPATCH@
diff -urNad fpc-2.2.0-dfsg1~/fpcsrc/packages/base/gdbint/gdbint.pp fpc-2.2.0-dfsg1/fpcsrc/packages/base/gdbint/gdbint.pp
--- fpc-2.2.0-dfsg1~/fpcsrc/packages/base/gdbint/gdbint.pp	2007-02-02 00:09:46.000000000 +0100
+++ fpc-2.2.0-dfsg1/fpcsrc/packages/base/gdbint/gdbint.pp	2008-03-15 18:40:31.000000000 +0100
@@ -71,6 +71,17 @@
   {$define GDB_HAS_DB_COMMANDS}
   {$define GDB_NEEDS_NO_ERROR_INIT}
   {$define GDB_USES_EXPAT_LIB}
+  {$define GDB_HAS_DEBUG_FILE_DIRECTORY}
+{$endif def GDB_V605}
+
+{ 6.7.x }
+{$ifdef GDB_V607}
+  {$info using gdb 6.7.x}
+  {$define GDB_V6}
+  {$define GDB_HAS_DB_COMMANDS}
+  {$define GDB_NEEDS_NO_ERROR_INIT}
+  {$define GDB_USES_EXPAT_LIB}
+  {$define GDB_HAS_DEBUG_FILE_DIRECTORY}
 {$endif def GDB_V605}
 
 {$ifdef GDB_V6}
@@ -207,14 +218,24 @@
   {$LINKLIB libhistory.a}
   {$LINKLIB libiberty.a}
   {$LINKLIB libintl.a}
-  {$LINKLIB libiconv.a}
-  {$LINKLIB libncurses.a}
-  {$ifdef GDB_USES_EXPAT_LIB}
-    {$LINKLIB expat}
-  {$endif GDB_USES_EXPAT_LIB}
-  {$LINKLIB gcc}
-  {$LINKLIB cygwin} { alias of libm.a and libc.a }
+  {$ifdef USE_MINGW_GDB}
+    {$LINKLIB libm.a}
+    {$LINKLIB libmoldname.a}
+    {$LINKLIB libgcc.a}
+    {$LINKLIB libws2_32.a}
+    {$LINKLIB libmingwex.a}
+    {$LINKLIB libmingw32.a}
+    {$LINKLIB libmsvcrt.a}
+  {$else not USE_MINGW_GDB}
+    {$LINKLIB libiconv.a}
+    {$LINKLIB libncurses.a}
+    {$ifdef GDB_USES_EXPAT_LIB}
+      {$LINKLIB expat}
+    {$endif GDB_USES_EXPAT_LIB}
+    {$LINKLIB gcc}
+    {$LINKLIB cygwin} { alias of libm.a and libc.a }
   {$LINKLIB imagehlp}
+  {$endif not USE_MINGW_GDB}	
   {$LINKLIB kernel32}
   {$LINKLIB user32}
 {$endif win32}
@@ -2151,6 +2172,7 @@
 procedure tgdbinterface.gdb_command(const s:string);
 var
   command          : array[0..256] of char;
+  prev_stop_breakpoint_number,
   mask : longint;
   s2 : string;
   old_quit_return,
@@ -2166,6 +2188,11 @@
   old_error_return:=error_return;
   gdb_error:=0;
   got_error:=false;
+  if command_level=1 then
+    prev_stop_breakpoint_number:=0
+  else
+    prev_stop_breakpoint_number:=stop_breakpoint_number;
+
   stop_breakpoint_number:=0;
   { Trap quit commands }
   s2:=s;
@@ -2213,6 +2240,7 @@
   quit_return:=old_quit_return;
   error_return:=old_error_return;
   dec(command_level);
+  stop_breakpoint_number:=prev_stop_breakpoint_number;
   SetFPUState(control);
 end;
 
@@ -2538,12 +2566,19 @@
     return_child_result_value : longint;cvar;public;
     batch_silent : longbool;cvar;public;
 {$endif}
+{$ifdef GDB_HAS_DEBUG_FILE_DIRECTORY}
+var
+  debug_file_directory : pchar; cvar; external;
+{$endif GDB_HAS_DEBUG_FILE_DIRECTORY}
 
 begin
 {$ifdef GDB_HAS_SYSROOT}
   gdb_sysrootc := #0;
   gdb_sysroot := @gdb_sysrootc;
 {$endif}
+{$ifdef GDB_HAS_DEBUG_FILE_DIRECTORY}
+  debug_file_directory := '/usr/local/lib';
+{$endif GDB_HAS_DEBUG_FILE_DIRECTORY}
   gdb_stderr:=nil;
   gdb_stdout:=nil;
   InitLibGDB;
